package DesignPatern.A20_状态模式.QSB.A01_基础模式;

/**
 * @Author: Du
 * @Date: 2021/8/6 9:29
 *
 * 环境角色类，串联各个状态的过度，在抽象类中的LiftSate中定义的环境角色聚合在一起
 */
public class Context
{
    public final static OpeningState open = new OpeningState();
    public final static ClosingState close = new ClosingState();
    public final static RunningState run = new RunningState();
    public final static StoppingState stop = new StoppingState();
    
    private LiftState liftState;
    
    public LiftState getLiftState()
    {
        return liftState;
    }
    
    public void setLiftState(LiftState liftState)
    {
        this.liftState = liftState;
        this.liftState.setContext(this);
    }
    
    public void open()
    {
        this.liftState.open();
    }
    
    public void close()
    {
        this.liftState.close();
    }
    
    public void run()
    {
        this.liftState.run();
    }
    
    public void stop()
    {
        this.liftState.stop();
    }
}
